from django.contrib import admin

# Register your models here.
from polls.models import Question, Choice

# 重写admin title 定制标题
admin.site.site_title = 'Chyang Management'
admin.site.site_header = 'Chyang Site'
admin.site.index_title = '首页'

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class QuestionAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,{'fields':['question_text']}),
        ('Date information',{'fields':['pub_date'],'classes':['collapse']}),
    ]
    inlines = [ChoiceInline]
    # 显示那些字段
    list_display = ('question_text','pub_date','was_published_recently')
    # 过滤器
    list_filter = ['pub_date']
    # 搜索器 按什么搜索
    search_fields = ['question_text']




admin.site.register(Question,QuestionAdmin)
admin.site.register(Choice)
